{
  "properties" : { },
  "id" : "copy1744541979697d42094",
  "script" : null,
  "groupId" : "cb8d8dda9f0d44b48220d5dbb9acf01f",
  "name" : "02_填写表单并提交",
  "createTime" : null,
  "updateTime" : 1744553411249,
  "lock" : null,
  "createBy" : null,
  "updateBy" : "可辉",
  "path" : "complete_copy",
  "method" : "POST",
  "parameters" : [ ],
  "options" : [ ],
  "requestBody" : "{\r\n    \"taskId\": \"fbb6a4a0-1870-11f0-8a2c-f4b3016ece8b\",\r\n    \"variables\":{\r\n        \"title\": \"湖南校园暴力2\",\r\n        \"`desc`\": \"descdescdescdescdescdescdesc\",\r\n        \"linkSource\": \"https://v.douyin.com/kREyEeL4vLc/\",\r\n        \"type\": 1\r\n    }\r\n}",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : "{\n    \"code\": 200,\n    \"msg\": \"success\",\n    \"data\": \"ok\"\n}",
  "description" : "对查询到的任务进行处理，指定任务id和表单提交",
  "requestBodyDefinition" : null,
  "responseBodyDefinition" : null
}
================================
import 'org.activiti.engine.RepositoryService' as repositoryService;
import 'org.activiti.engine.RuntimeService' as runtimeService;
import 'org.activiti.engine.TaskService' as taskService;
import 'com.wiwf.model.security.service.SysTokenService' as sysTokenService;
import org.activiti.api.process.model.ProcessInstance;
import org.activiti.engine.task.Task;
import log;

var user = sysTokenService.getTokenUser(cookie[sysTokenService.getTokenKey()]);
var roleCode = user.roleCode;
var userId = user.userId;
var unitId = user.unitId;
    
    body.variables['userId'] = userId;
    body.variables['unitId'] = unitId;

    Task task = taskService.createTaskQuery().taskId(body.taskId).singleResult();
    if(! task){
        exit 401, "任务不存在"
    }
    var formKey= task.getFormKey().toLowerCase();
    
    try {
        db.table(formKey).primary('id').save(body.variables);

        var completeBody = body.variables;
        completeBody['role'] = roleCode;
        taskService.complete(body.taskId, body.variables);
    } catch(e) {
        exit 401, e.message
    }

return "ok";